<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>

<div class="btn-group inline-block">
	<t:button icon="icon-file-upload2 text-primary" onclick="upload()">上传</t:button>
	<t:button icon="icon-folder text-primary" onclick="createFolder()">新建文件夹</t:button>
</div>
<div class="hide">
	<input type="file" class="file-input" data-show-caption="false" data-show-upload="false" data-browse-class="btn btn-primary btn-lg" data-remove-class="btn btn-default btn-lg">
</div>
<script type="text/javascript">
	function createFolder(){
		
		prompt("请输入文件夹名称","新建文件夹",function(folder){
			if($.isNull(folder)){
				return;
			}
			var url=$.getVirtualPath()+"/admin/document/fileCatalog/newFolder";
			
			var parentId=$("#parentId").val();
			var parentLevel=$("#parentLevel").val();
			var data="parentId="+parentId+"&folderName="+folder+"&parentLevel="+parentLevel;
			
			var result=$.getJsonPost(url,data);
			if(result.resultType=="success"){
				loadOutput();
			}
		});
	}
	
	function upload(){
		var folderId=$("#parentId").val();
		top.startUpload("multiple",folderId);
		
		top.uploadFinishCallback=uploadCallback;
	}
	
	function uploadCallback(){
		loadOutput();
	}
	
	function loadOutput(){
		var parentId=$("#parentId").val();
		var url=$.getVirtualPath()+"/admin/document/fileCatalog/output?parentId="+parentId;
		var outputHtml=$.getTextPost(url);
		
		$(".outputContent").html(outputHtml);
	}
	
</script>